package com.mall.common.service;

import java.util.List;
import java.util.Map;

import org.springframework.web.multipart.MultipartFile;

import com.mall.common.CommonSetting;
import com.mall.common.bean.FileInfo;
import com.mall.common.bean.FileInfo.FileType;
import com.mall.common.bean.FileInfo.OrderType;
import com.mall.common.enums.UploadType;


public interface FileService {
	
	public abstract boolean isValid(FileType filetype, MultipartFile multipartfile, CommonSetting setting);

	/**
	 * 文件上传(会根据系统配置生成文件名)
	 * @param filetype
	 * @param uploadFile
	 * @param async 是否异步 true: 是异步, false: 同步
	 * @param contentType
	 * @param fileName
	 * @param componentId
	 * @param uploadType 上传类型
	 * @param extra 额外的参数
	 * @return
	 */
	public String upload(FileType fileType, MultipartFile multipartFile, boolean async, String componentId, UploadType uploadType, Map<String, Object> extra, CommonSetting setting);
	
	/**
	 * 上传到临时文件夹
	 * @param fileType
	 * @param multipartFile
	 * @param async
	 * @param extra
	 * @return
	 */
	public String uploadTemp(FileType fileType, MultipartFile multipartFile, boolean async, Map<String, Object> extra, CommonSetting setting);
	
	/**
	 * 移动本地文件
	 * @param path 文件地址
	 * @param async 是否异步
	 * @param uploadType 上传类型
	 * @param componentId 目标组件
	 * @return
	 */
	public String moveFile(FileType fileType, String path, UploadType uploadType, String componentId, Map<String, Object> extra, CommonSetting setting);
	
	/**
	 * 复制文件
	 * @param fileType
	 * @param path
	 * @param uploadType
	 * @param componentId
	 * @param extra
	 * @return
	 */
	public String copyFile(FileType fileType, String path, UploadType uploadType, String componentId, Map<String, Object> extra, CommonSetting setting);
	
	public abstract List<FileInfo> browser(UploadType uploadType, String path, FileType filetype, OrderType ordertype, String componentId, CommonSetting setting);
	
	/**
	 * 切图
	 * @param path 原图路径
	 * @param axisX x轴
	 * @param axisY y轴
	 * @param height 高度
	 * @param width 宽度
	 * @param uploadType 上传类型
	 * @param extra 额外的参数
	 * @return
	 */
	public String cutImage(String path, Integer boxWidth, Integer boxHeight, Integer axisX, Integer axisY, Integer height, Integer width, UploadType uploadType, Map<String, Object> extra, CommonSetting setting);
}
